<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{massage}}</h1>
        <h1 v-bind:title="title">将鼠标悬浮</h1>
        <h1 :title="title">将鼠标悬浮</h1>
        <!-- 【v-bind:属性名】和【:属性名】两种方式都可以绑定属性 -->

        <button v-on:click="fun">按钮</button><br>
        <button @click="fun">按钮</button><br>
        <!-- 【v-on:事件类型】和【@事件类型】两种方式都可以为元素绑定事件 -->

        <button @click="changeTitle">改变标题</button><br>

        <form action="" @submit.prevent="postData">
            <input type="submit"><br>
        </form>
        <!-- .prevent:组织元素的默认行为 -->

        <button @click.once="onceData">提交一次</button>
    </div>
    <script src="script/vue.js"></script>
    <script>
        const vue = new Vue({
            data : {
                massage : "hello Vue",
                title : "绑定属性"
            },
            methods : {
                fun(){
                    alert("绑定事件")
                },
                changeTitle(){
                    this.massage = "hello world"
                },
                postData(){
                    console.log("提交数据")
                },
                onceData(){
                    console.log("提交一次")
                }
            }
        })
        vue.$mount("#app"); //$mount方法，将Vue挂载到html
    </script>
</body>
</html>